<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>

        $(function () {

            let trs = $("tr");
            for (let i = 0; i < trs.length; i++) {
                if (i % 2 === 0 && i !== 0) {
                    trs[i].style.backgroundColor = "#c7decc"
                }
                if (i % 2 === 1) {
                    trs[i].style.backgroundColor = "#c4e3f3";
                }
            }
        })

    </script>

</head>
<body>
<table id="tab1" border="1" width="400" align="center">
    <tr style="background-color: #808080;">
        <th>ID</th>
        <th>姓名</th>
        <th>专业</th>
    </tr>
    <tr>
        <td>20180201</td>
        <td>刘备</td>
        <td>全栈</td>
    </tr>
    <tr>
        <td>20180202</td>
        <td>曹操</td>
        <td>java</td>
    </tr>
    <tr>
        <td>20180203</td>
        <td>孙权</td>
        <td>Python</td>
    </tr>
    <tr>
        <td>20180204</td>
        <td>刘表</td>
        <td>大数据</td>
    </tr>

</table>
</body>
</html>